#include "Course.h"
#include <iostream>
#include <iomanip>

// 初始化静态成员，默认第一个课程ID为1
int Course::currentId = 1;

// 无参数构造函数
Course::Course()
{
    id = currentId++;// 将currentId当前值赋值给id，再将currentID自增
    name = "";// 默认课程名称为空字符串
}
// 课程类构造函数：根据课程名称创建课程对象
Course::Course(const string& cName):Course()
{
    name=cName;
}
// 课程类拷贝构造函数
Course::Course(const Course &course):Course()
{
    id=course.id;
    name=course.name;
}


// 打印课程信息
void Course::PrintInfo() const
{
    // cout<<setiosflags(ios_base::left)<<setw(10)<<"id:"<<id<<endl;
    // cout<<setiosflags(ios_base::left)<<setw(10)<<"name:"<<name<<endl;
    cout << "Course: " << id << " : " << name << endl;
}
// 操作符<<重载函数，当cout<<输出课程信息时使用
ostream &operator<<(ostream &out, const Course &course)
{
    // out<<setiosflags(ios_base::left)<<setw(10)<<"id:"<<course.id<<endl;
    // out<< setiosflags(ios_base::left)<<setw(10)<<"name:"<<course.name<<endl;
    // return out;

    out << "Course: " << course.id << " : " << course.name;
    return out;
}

// 友元函数：读取输入创建新的课程
void read(istream &inputStream, Course &course)
{
    // cout<<setiosflags(ios_base::left)<<setw(10)<<"id:";
    // inputStream>>course.id;
    // cout<< setiosflags(ios_base::left)<<setw(10)<<"name:";
    // inputStream>>course.name;
    inputStream >> course.name;
}








// 项目课打印课程信息
void ProjectCourse::PrintInfo() const
{
    // Course::PrintInfo();
    // cout<<setiosflags(ios_base::left)<<setw(10)<<"tag:"<<tag<<endl;

    cout << "ProjectCourse: " << id << " : " << name << " : " << tag << endl;
}





// 评估课打印课程信息
void EvaluationCourse::PrintInfo() const
{
    // Course::PrintInfo();
    // cout<<setiosflags(ios_base::left)<<setw(10)<<"limit time:"<<limTime<<endl;
    cout << "JudgeCourse: " << id << " : " << name << " : " << limTime << endl;
}